package game.model.building.vo 
{
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author Thot
	 */
	 
	public class BuildingVO 
	{
		private var _increasing:Boolean;
		private var _increaseStartTime:int;
		
		public var nextLevelTime:int;
		public var name:String;
		public var id:int;
		public var level:int;
		public var prodMana:int;
		public var prodGold:int;
		public var costMana:int;
		public var costGold:int;
		public var costGems:int;
		
		
		
		public function BuildingVO() 
		{
			costMana	= 0;
			costGold	= 0;
			costGems	= 0;
			prodMana 	= 0;
			prodGold 	= 0;
			id 			= 0;
			level 		= 0;
			name 		= "";
			
			nextLevelTime = 0;
			_increasing = false;
			_increaseStartTime = 0;
		}
		
		public function startIncrease():void
		{
			_increaseStartTime = getTimer();
			_increasing = true;
		}
		
		public function get elapsedTime():int
		{
			return ( getTimer() - _increaseStartTime ) / 1000;
		}
		
		public function get timeLeft():int
		{
			return ( nextLevelTime - elapsedTime );
		}
		
		public function hasReachedNextLevel():Boolean
		{
			var time:int = getTimer();
			if ( _increasing )
			{
				if (_increasing && elapsedTime >= nextLevelTime )
				{
					_increasing = false;
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		
		public function isIncreasing():Boolean
		{
			return _increasing;
		}
		
		public function destroy():void
		{
			costMana	= 0;
			costGold	= 0;
			costGems	= 0;
			prodMana 	= 0;
			prodGold 	= 0;
			id 			= 0;
			level 		= 0;
			name 		= null;
			
			nextLevelTime = 0;
			_increasing = false;
			_increaseStartTime = 0;
		}
		
	}

}